package br.ufrgs.tcp.model;

import java.io.IOException;
import java.util.List;

import android.database.Cursor;
import br.ufrgs.tcp.db.AdapterFactory;
import br.ufrgs.tcp.db.AdapterFactory.AdapterType;
import br.ufrgs.tcp.db.SQLAdapter;
import br.ufrgs.tcp.fetch.StaticSalaFetcher;
import br.ufrgs.tcp.fetch.base.IProduceData;

public class Sala implements IModel {

	static { adapter = AdapterFactory.create(AdapterType.SALA); }
	private static SQLAdapter adapter;

	int numero;
	int numeroPredio;
	
	public int getNumero() {
		return numero;
	}
	
	public int getNumeroPredio() {
		return numeroPredio;
	}
	
	public Sala(int numero, int numeroPredio) {
		this.numero = numero;
		this.numeroPredio = numeroPredio;
	}

	private Sala() {
		
	}

	@Override
	public ModelType getModelType() {
		return ModelType.SALA;
	}

	@Override
	public String getModelName() {
		return "Salas";
	}

	@Override
	public	void updateDataBase(List<? extends IModel> data) {
		adapter.open();
		adapter.deleteAll();
		adapter.bulkInsert(data);
		adapter.close();
	}

	@Override
	public  List<Sala> fetchData() throws IOException {
		IProduceData<Sala> producer = new StaticSalaFetcher();
		return producer.produdceData();
	}

	public static Cursor fetchByNumero(String text) {
		adapter.open();	
		
		Cursor c = adapter.fetchByNumero(text);
		return c;
	}

	public static Sala getDummy() {
		return new Sala();
}



}
